#lang racket


(require "../base/base.rkt")

(require "domain.rkt"
         "curve.rkt"
         "parametric.rkt")


(provide (struct-out straight-curve))


(define-struct (straight-curve curve)
  (start end)
  #:constructor-name new-straight-curve)


(define (straight-curve-object start end)
  (λ (t)
    (p+p
     (p*n start (- 1 t))
     (p*n end t))))

(define (straight-curve-tangent start end)
  (λ (t)
    (unit (p-p end start))))

(define (straight-curve-normal start end)
  (λ (t)
    (raise unsupported "The normal is not defined for a straight line")))

(define (straight-curve-binormal start end)
  (λ (t)
    (raise unsupported "The binormal is not defined for a straight line")))

(define (make-straight-curve start end)
  (new-straight-curve
   (make-domain 'closed 0 'closed 1)
   (straight-curve-object start end)
   (straight-curve-tangent start end)
   (straight-curve-normal start end)
   (straight-curve-binormal start end)
   start
   end))